#include <bits/stdc++.h>

using namespace std;
struct Fraction
{
    int numerator;
    int denominator;
};
extern int gcd2(int a,int b);
Fraction reduction(Fraction fraction)
{
    if (fraction.denominator<0)
    {
        fraction.numerator*=-1;
        fraction.denominator*=-1;
    }
    if (fraction.numerator==0)
    {
        fraction.denominator=1;
    }
    int greatest_common_divisor=gcd2(abs(fraction.numerator),abs(fraction.denominator));
    fraction.numerator/=greatest_common_divisor;
    fraction.denominator/=greatest_common_divisor;
    return fraction;
}
Fraction add(Fraction f1,Fraction f2)
{
    Fraction sum;
    sum.denominator=f1.denominator*f2.denominator;
    sum.numerator=f1.numerator*f2.denominator+f1.denominator*f2.numerator;
    return reduction(sum);
}
int main_118()
{
    srand((unsigned)time(0));
    int len=20;
    Fraction f[len];
    for (int i=0;i<len ;++i )
    {
        f[i].numerator=rand()%100;
        f[i].denominator=rand()%100;
    }
    for (int i=0;i<len ;++i )
    {
        printf("%d/%d ",f[i].numerator,f[i].denominator);
        f[i]=reduction(f[i]);
    }
    printf("\n");
    for (int i=0;i<len ;++i )
    {
        printf("%d/%d ",f[i].numerator,f[i].denominator);
    }
    printf("\n");
    Fraction a={1,2},b={2,4},c;
    c=add(a,b);
    printf("%d/%d",c.numerator,c.denominator);
    return 0;
}
